package user.main;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

import commonfunctions.Matrix;

import fileparsing.ReadObservations;
import fileparsing.ReadProbabilities;
import guiobjects.Observation;

public class RunListWeights 
{
	private static double interval = 1.0 / 32;
	public static void main(String[] args)
	{
		try
		{
			System.out.println("What directory should be used for the file?");
	    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    	String dirName = br.readLine();
	    	ArrayList<Observation> obs = ReadObservations.listOfObservations(dirName);
	    	Matrix weights = ReadProbabilities.probabilityMatrix(dirName);
	    	int[] numInEachCategory = new int[(int)(2.0 / interval)];
	    	int[] numInEachCategorySame = new int[(int)(2.0 / interval)];
	    	for (int i = 0; i < weights.length(); i++)
	    	{
	    		for (int j = 0; j < weights.length(); j++)
	    		{
	    			if (weights.get(i, j) > -1.0)
	    				numInEachCategory[(int)((1+weights.get(i, j)) / interval)]++;
	    		}
	    	}
	    	System.out.println("All edge weights:");
	    	for (int i = 0; i < numInEachCategory.length; i++)
	    	{
	    		//if (numInEachCategory[i] > 0)
		    		//System.out.println("There are " + numInEachCategory[i] + " values with weights from " + 
		    			//	(-1.0 + i*interval) + " to " + (-1.0 + (i+1)*interval) + ".");
	    			System.out.print(Math.min(numInEachCategory[i], 2500) + ",");
	    	}
	    	System.out.println();
	    	System.out.println("Edge weights connecting observations of the same object:");
	    	for (int i = 0; i < weights.length(); i++)
	    	{
	    		for (int j = 0; j < weights.length(); j++)
	    		{
	    			if (weights.get(i, j) > -1.0 && obs.get(i).id == obs.get(j).id)
	    				numInEachCategorySame[(int)((1+weights.get(i, j)) / interval)]++;
	    		}
	    	}
	    	for (int i = 0; i < numInEachCategorySame.length; i++)
	    	{
		    		//System.out.println("There are " + numInEachCategory[i] + " values with weights from " + 
		    			//	(-1.0 + i*interval) + " to " + (-1.0 + (i+1)*interval) + ".");
	    			System.out.print(Math.min(numInEachCategorySame[i], 2500) + ",");
	    	}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
